Dynamic lookup service in a distributed system

ABSTRACT

An improved lookup service is provided that allows for the dynamic addition and deletion of services. This lookup service allows for the addition and deletion of services automatically, without user intervention. As a result, clients of the lookup service may continue using the lookup service and its associated services while the updates occur. Additionally, the lookup service provides a notification mechanism that can be used by clients to receive a notification when the lookup service is updated. By receiving such a notification, clients can avoid attempting to access a service that is no longer available and can make use of new services as soon as they are added to the lookup service.

RELATED APPLICATIONS

This application is a continuation-in-part of U.S. patent applicationSer. No. 09/044,931, filed on Mar. 20, 1998, which is incorporated byreference.

The following identified U.S. patent applications are relied upon andare incorporated by reference in this application.

U.S. Provisional Application No. 60/138,680, entitled “Jini™ TechnologyHelper Utilities and Services,” bearing attorney docket no.06502.6010-00000.

Provisional U.S. Patent Application No. 60/076,048, entitled“Distributed Computing System,” filed on Feb. 26, 1998.

U.S. patent application Ser. No. 09/044,923, entitled “Method and Systemfor Leasing Storage,” bearing attorney docket no. 06502.0011-01000.

U.S. patent application Ser. No. 09/044,838, entitled “Method, Apparatusand Product for Leasing of Delegation Certificates in a DistributedSystem,” bearing attorney docket no. 06502.0011-02000.

U.S. patent application Ser. No. 09/044,834, entitled “Method, Apparatusand Product for Leasing of Group Membership in a Distributed System,”bearing attorney docket no. 06502.0011-03000.

U.S. patent application Ser. No. 09/044,933, entitled “Method forTransporting Behavior in Event Based System,” bearing attorney docketno. 06502.0054-00000.

U.S. patent application Ser. No. 09/044,919, entitled “DeferredReconstruction of Objects and Remote Loading for Event Notification in aDistributed System,” bearing attorney docket no. 06502.0062-01000.

U.S. patent application Ser. No. 09/045,652, entitled “Method and Systemfor Deterministic Hashes to Identify Remote Methods,” bearing attorneydocket no. 06502.0103-00000.

U.S. patent application Ser. No. 09/044,790, entitled “Method andApparatus for Determining Status of Remote Objects in a DistributedSystem,” bearing attorney docket no. 06502.0104-00000.

U.S. patent application Ser. No. 09/044,930, entitled “DownloadableSmart Proxies for Performing Processing Associated with a RemoteProcedure Call in a Distributed System,” bearing attorney docket no.06502.0105-00000.

U.S. patent application Ser. No. 09/044,917, entitled “Suspension andContinuation of Remote Methods,” bearing attorney docket no.06502.0106-00000.

U.S. patent application Ser. No. 09/044,835, entitled “Method and Systemfor Multi-Entry and Multi-Template Matching in a Database,” bearingattorney docket no. 06502.0107-00000.

U.S. patent application Ser. No. 09/044,839, entitled “Method and Systemfor In-Place Modifications in a Database,” bearing attorney docket no.06502.0108.

U.S. patent application Ser. No. 09/044,945, entitled “Method and Systemfor Typesafe Attribute Matching in a Database,” bearing attorney docketno. 06502.0109-00000.

U.S. patent application Ser. No. 09/044,939, entitled “Apparatus andMethod for Providing Downloadable Code for Use in Communicating with aDevice in a Distributed System,” bearing attorney docket no.06502.0112-00000.

U.S. patent application Ser. No. 09/044,826, entitled “Method and Systemfor Facilitating Access to a Lookup Service,” bearing attorney docketno. 06502.0113-00000.

U.S. patent application Ser. No. 09/044,932, entitled “Apparatus andMethod for Dynamically Verifying Information in a Distributed System,”bearing attorney docket no. 06502.0114-00000.

U.S. patent application Ser. No. 09/030,840, entitled “Method andApparatus for Dynamic Distributed Computing Over a Network,” and filedon Feb. 26, 1998.

U.S. patent application Ser. No. 09/044,936, entitled “An InteractiveDesign Tool for Persistent Shared Memory Spaces,” bearing attorneydocket no. 06502.0116-00000.

U.S. patent application Ser. No. 09/044,934, entitled “PolymorphicToken-Based Control,” bearing attorney docket no. 06502.0117-00000.

U.S. patent application Ser. No. 09/044,915, entitled “Stack-BasedAccess Control,” bearing attorney docket no. 06502.0118-00000.

U.S. patent application Ser. No. 09/044,944, entitled “Stack-BasedSecurity Requirements,” bearing attorney docket no. 06502.0119-00000.

U.S. patent application Ser. No. 09/044,837, entitled “Per-MethodDesignation of Security Requirements,” bearing attorney docket no.06502.0120-00000.

FIELD OF THE INVENTION

The present invention relates generally to data processing systems and,more particularly, to a dynamic lookup service in a distributed system.

BACKGROUND OF THE INVENTION

A lookup service contains an indication of where network services arelocated within a distributed system comprised of multiple machines, suchas computers and related peripheral devices, connected in a network (forexample, a local area network, wide area network, or the Internet). A“network service” refers to a resource, data, or functionality that isaccessible on the network. Typically, for each service, the lookupservice contains an address used by a client (e.g., a program) to accessthe service (e.g., a printer).

Conventional lookup services are static: whenever updates to the lookupservice are needed to either add a new service or delete an existingservice, the lookup service is taken offline, rendering the lookupservice inaccessible, and then, the lookup service is manually updatedby the system administrator. During the time when the lookup service isoffline, clients in the distributed system are unable to access thelookup service and any of its network services. Another limitation ofconventional lookup services is that, when updated, clients are not madeaware of the updates to the lookup service until they explicitly performa refresh operation, which downloads the latest service information tothe clients. Before such a refresh, however, if a client requests aservice that is no longer available, an error occurs which may cause theclient to hang. Also, before a refresh, the client is not aware of anynew services that have been recently added to the lookup service. It istherefore desirable to improve lookup services for distributed systems.

SUMMARY OF THE INVENTION

Systems consistent with the present invention provide an improved lookupservice that allows for the dynamic addition and deletion of services.This lookup service allows for the update, i.e., addition and deletionof available services automatically, without user intervention. As aresult, clients of the lookup service may continue using the lookupservice and its associated services while the updates occur.Additionally, the lookup service provides a notification mechanism thatcan be used by clients to receive a notification when the lookup serviceis updated. By receiving such a notification, clients can avoidattempting to access a service that is no longer available and can makeuse of new services as soon as they are added to the lookup service.

In accordance with methods consistent with the present invention, amethod is provided in a data processing system having a lookup servicewith associated services. This method receives a request by the lookupservice for notification when the lookup service is updated, determineswhen the lookup service is updated, and generates a notification when itis determined that the lookup service is updated.

In accordance with methods consistent with the present invention, amethod is provided in a data processing system having a lookup servicewith associated services. This method sends a request to the lookupservice to be notified when the lookup service is updated and receivesan indication that the lookup service has been updated.

In accordance with methods consistent with the present invention, amethod is provided in a data processing system having a lookup servicewith associated services and a client lookup manager with an associatedcache. This method transmits an event by the lookup service thatidentifies a change to one of the associated network services. Theclient lookup manager receives the event and updates the associatedcache to reflect the change.

In accordance with methods consistent with the present invention, amethod is provided in a data processing system having a client andlookup service with associated services. This method receives a requestfrom a client for access to a network service, then retrieves areference from a cache reflecting a particular network servicecorresponding to the requested network service and transmits thereference to the client.

In accordance with systems consistent with the present invention, a dataprocessing system comprising a memory and a processor is provided. Thememory includes a lookup service containing indications of services thatare available for use, a first client for updating the lookup service,and a second client for utilizing the lookup service while the firstclient is updating the lookup service. The processor runs the lookupservice, the first client, and the second client.

In accordance with systems consistent with the present invention, a dataprocessing system containing a memory and a processor is provided. Thememory contains a lookup service with indications of services availablefor use and a client. The lookup service receives requests fornotification of when the lookup service is updated, determines when thelookup service is updated, and generates notifications when the lookupservice is updated. The client sends a request to the lookup service tobe notified when the lookup service is updated. The processor runs theclient and the lookup service.

In accordance with systems consistent with the present invention, a dataprocessing system containing a memory and a processor is provided. Thememory contains a lookup service with references to a plurality ofnetwork services available for use, a client, and a client lookupmanager with an associated cache stored on the client computer. Theclient lookup manager accesses the lookup service and stores servicereferences in the cache. The processor runs the client and the lookupservice.

In accordance with systems consistent with the present invention, acomputer-readable memory device containing a data structure is provided.This data structure is for accessing a lookup service with associatednetwork services available for use. The data structure contains a notifymethod for use by a client to register with the lookup service toreceive a notification from the lookup service when the lookup serviceis updated.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which are incorporated in and constitute apart of this specification, illustrate an implementation of theinvention and, together with the description, serve to explain theadvantages and principles of the invention. In the drawings,

FIG. 1 depicts a distributed system suitable for practicing methods andsystems consistent with the present invention;

FIG. 2 depicts a more detailed block diagram of a computer depicted inFIG. 1;

FIGS. 3A and 3B depict a flow chart of the steps performed when a clientutilizes the lookup service depicted in FIG. 1;

FIG. 4 depicts a flow chart of the steps performed by the lookup serviceof FIG. 1 when performing event-related processing;

FIG. 5 depicts a conference room containing a number of devicesconsistent with the present invention;

FIG. 6 depicts a screen displaying icons representing services availablein the conference room of FIG. 5;

FIG. 7 depicts a screen displaying the available services provided by acomputer in the conference room of FIG. 5;

FIG. 8 depicts an alternate embodiment of the computer depicted in FIG.2;

FIG. 9 depicts a flow chart of the steps performed by the client lookupmanager of FIG. 8 when populating the cache;

FIG. 10 depicts a flow chart of the steps performed by the filteringalgorithm contained within the client lookup manager;

FIG. 11 depicts a flow chart of the steps performed by a first queryprocessing algorithm contained within the client lookup manager;

FIG. 12 depicts a flow chart of the steps performed by a second queryprocessing algorithm contained within the client lookup manager; and

FIG. 13 depicts a flow chart of the steps performed by a notificationprocess contained within the client lookup manager.

DETAILED DESCRIPTION OF THE INVENTION

Methods and systems consistent with the present invention provide animproved lookup service that allows for the dynamic addition anddeletion of services. As such, the addition and deletion of services isperformed automatically, without user intervention, and clients of thelookup service may continue using the services while the updates to thelookup service occur. Additionally, clients may register with the lookupservice to receive notification of when the lookup service is updated.As a result, when an update occurs, all registered clients receive anotification of the update, enabling the clients to avoid attempting toaccess a service that is no longer available and to use a servicerecently added to the lookup service.

Overview of The Distributed System

Methods and systems consistent with the present invention operate in adistributed system (“the exemplary distributed system”) with variouscomponents, including both hardware and software. The exemplarydistributed system (1) allows users of the system to share services andresources over a network of many devices; (2) provides programmers withtools and programming patterns that allow development of robust, secureddistributed systems; and (3) simplifies the task of administering thedistributed system. To accomplish these goals, the exemplary distributedsystem utilizes the Java™ programming environment to allow both code anddata to be moved from device to device in a seamless manner.Accordingly, the exemplary distributed system is layered on top of theJava programming environment and exploits the characteristics of thisenvironment, including the security offered by it and the strong typingprovided by it. The Java programming environment is more clearlydescribed in Jaworski, Java 1.1 Developer's Guide, Sams.net (1997),which is incorporated herein by reference.

In the exemplary distributed system, different computers and devices arefederated into what appears to the user to be a single system Byappearing as a single system, the exemplary distributed system providesthe simplicity of access and the power of sharing that can be providedby a single system without giving up the flexibility and personalizedresponse of a personal computer or workstation. The exemplarydistributed system may contain thousands of devices operated by userswho are geographically disperse, but who agree on basic notions oftrust, administration, and policy. Within the exemplary distributedsystem are various logical groupings of services provided by one or moredevices, and each such logical grouping is known as a Djinn. A “service”refers to a resource, data, or functionality that can be accessed by auser, program, device, or another service and that can be computational,storage related, communication related, or related to providing accessto another user. Examples of services provided as part of a Djinninclude devices, such as printers, displays, and disks; software, suchas applications or utilities; information, such as databases and files;and users of the system.

Both users and devices may join a Djinn. When joining a Djinn, the useror device adds zero or more services to the Djinn and may access,subject to security constraints, any one of the services it contains.Thus, devices and users federate into a Djinn to share access to itsservices. The services of the Djinn appear programmatically as objectsof the Java programming environment, which may include other objects,software components written in different programming languages, orhardware devices. A service has an interface defining the operationsthat can be requested of that service, and the type of the servicedetermines the interfaces that make up that service.

FIG. 1 depicts the exemplary distributed system 100 containing acomputer 102, a computer 104, and a device 106 interconnected by anetwork 108. The device 106 may be any of a number of devices, such as aprinter, fax machine, storage device, input device, computer, or otherdevices. The network 108 may be a local area network, wide area network,or the Internet. Although only two computers and one device are depictedas comprising the exemplary distributed system 100, one skilled in theart will appreciate that the exemplary distributed system 100 mayinclude additional computers or devices.

FIG. 2 depicts the computer 102 in greater detail to show a number ofthe software components of the exemplary distributed system 100. Oneskilled in the art will appreciate that computer 104 or device 106 maybe similarly configured. Computer 102 includes a memory 202, a secondarystorage device 204, a central processing unit (CPU) 206, an input device208, and a video display 210. The memory 202 includes a lookup service212, a discovery server 214, and a Java runtime system 216. The Javaruntime system 216 includes the Java remote method invocation system(RMI) 218 and a Java virtual machine 220. The secondary storage device204 includes a Java space 222.

As mentioned above, the exemplary distributed system 100 is based on theJava programming environment and thus makes use of the Java runtimesystem 216. The Java runtime system 216 includes the Java ApplicationProgramming Interface (API), allowing programs running on top of theJava runtime system to access, in a platform-independent manner, varioussystem functions, including windowing capabilities and networkingcapabilities of the host operating system. Since the Java API provides asingle common API across all operating systems to which the Java runtimesystem 216 is ported, the programs running on top of a Java runtimesystem run in a platform-independent manner, regardless of the operatingsystem or hardware configuration of the host platform. The Java runtimesystem 216 is provided as part of the Java software development kitavailable from Sun Microsystems of Mountain View, Calif.

The Java virtual machine 220 also facilitates platform independence. TheJava virtual machine 220 acts like an abstract computing machine,receiving instructions from programs in the form of bytecodes andinterpreting these bytecodes by dynamically converting them into a formfor execution, such as object code, and executing them. RMI 218facilitates remote method invocation by allowing objects executing onone computer or device to invoke methods of an object on anothercomputer or device. Both RMI and the Java virtual machine are alsoprovided as part of the Java software development kit.

The lookup service 212 defines the services that are available for aparticular Djinn. That is, there may be more than one Djinn and,consequently, more than one lookup service within the exemplarydistributed system 100. The lookup service 212 contains one object foreach service within the Djinn, and each object contains various methodsthat facilitate access to the corresponding service. The lookup service212 and its access are described in greater detail in co-pending U.S.patent application Ser. No. 09/044,826, entitled “Method and System forFacilitating Access to a Lookup Service,” which has previously beenincorporated by reference.

The discovery server 214 detects when a new device is added to theexemplary distributed system 100, during a process known as boot andjoin or discovery, and when such a new device is detected, the discoveryserver passes a reference to the lookup service 212 to the new device,so that the new device may register its services with the lookup serviceand become a member of the Djinn. After the device discovers the lookupservice 212, the device may access any of the services registered withthe lookup service 212. Furthermore, the device may also advertise itsown services by registering with the lookup service 212. Onceregistered, the services provided by the device may be accessed throughthe lookup service 212, by all other entities that also discover lookupservice 212. The process of boot and join is described in greater detailin co-pending U.S. patent application Ser. No. 09/044,939, entitled“Apparatus and Method for providing Downloadable Code for Use inCommunicating with a Device in a Distributed System,” which haspreviously been incorporated by reference.

The Java space 222 is an object repository used by programs within theexemplary distributed system 100 to store objects. Programs use the Javaspace 222 to store objects persistently as well as to make themaccessible to other devices within the exemplary distributed system.Java spaces are described in greater detail in co-pending U.S. patentapplication Ser. No. 08/971,529, entitled “Database System EmployingPolymorphic Entry and Entry Matching,” assigned to a common assignee,filed on Nov. 17, 1997, which is incorporated herein by reference. Oneskilled in the art will appreciate that the exemplary distributed system100 may contain many lookup services, discovery servers, and Javaspaces.

Although systems and methods consistent with the present invention aredescribed as operating in the exemplary distributed system and the Javaprogramming environment, one skilled in the art will appreciate that thepresent invention can be practiced in other systems and otherprogramming environments. Additionally, although aspects of the presentinvention are described as being stored in memory, one skilled in theart will appreciate that these aspects can also be stored on or readfrom other types of computer-readable media, such as secondary storagedevices, like hard disks, floppy disks, or CD-ROM; a carrier wave fromthe Internet; or other forms of RAM or ROM. Sun, Sun Microsystems, theSun Logo, Java, and Java-based trademarks are trademarks or registeredtrademarks of Sun Microsystems, Inc. in the United States and othercountries

The Lookup Service Definition

A lookup service provides a central registry of services availablewithin a Djinn. This lookup service is the primary mechanism forprograms to find services within the Djinn and is the foundation forproviding user interfaces through which users and administrators candiscover and interact with services of the Djinn.

The lookup service maintains a flat collection of service items. Thecollection is flat in that the service items do not form a hierarchy.Each service item represents an instance of a service available withinthe Djinn. The service item contains a stub (if the service isimplemented as a remote object) or a serialized object (if the serviceis a local object stored in the lookup service) that programs use toaccess the service, and an extensible collection of attributes thatdescribe the service or provide secondary interfaces to the service. A“stub” is code and data that facilitates access to a remote function,and a “serialized object” is an object placed in a serialized form.

Although the collection of service items is flat, a wide variety ofhierarchical views can be imposed on the collection by aggregating itemsaccording to service types and attributes. The lookup service provides aset of methods to enable users and administrators to browse thecollection and build a variety of user interfaces. Once an appropriateservice is found, the user can interact with the service by loading auser interface applet, attached as another attribute on the item.

When a new service is created (e.g., when a new device is added to aDjinn), the service registers itself with the lookup service, providingan initial collection of attributes. For example, a printer may includeattributes indicating speed (in pages per minute), resolution (in dotsper inch), and whether duplex printing is supported. The attributes alsocontain an indicator that the service is new and needs to be configured.To configure a new service, the administrator locates an attribute thatprovides an applet for this purpose, and during configuration, theadministrator may add new attributes, such as the physical location ofthe service and a common name for it. The lookup service provides anevent mechanism that generates notifications as new services areregistered, existing services are deleted, or attributes of a serviceare modified. To use the event mechanism, a client registers to benotified upon the occurrence of a particular event, and when the eventoccurs, the lookup service notifies the client.

Programs (including other services) that need a particular type ofservice can use the lookup service to find an instance of the service. Amatch may be made based on the specific Java programming language typesimplemented by the service as well as the specific attributes attachedto the service.

If a service encounters a problem that needs administrative attention,like a printer running out of toner, the service can add an attributethat indicates the problem. Administrators (or programs) can then usethe event mechanism to receive notification of such problems.

The attributes of a service item are represented as a set of attributesets. An individual set of attributes may be represented as an instanceof a class in the Java programming language, each attribute being apublic field of that class. The class provides strong typing of both theset and the individual attributes. A service item can contain multipleinstances of the same class with different attribute values as well asmultiple instances of different classes. For example, an item may havemultiple instances of a Name class, each giving the common name of theservice in a different language, plus an instance of a Location class,an Owner class, and various service-specific classes.

Service Items are stored in the lookup service as instances of theServiceltem class, as described below: public class Service Item {    public static final long ASSIGN_SERVICE_ID = 0;     public longserviceID;     public Object service;     public Entry [ ]attributeSets; }The “serviceID” element is a numerical identifier of the service. The“service” element is an object representing the service or a stubfacilitating access to the service, and the “attributeSets” elementcontains the array of attributes for the service.

Items in the lookup service are matched using instances of theServiceTemplate class, and the ServiceItemFilter interface which aredefined below: public class Service Template {     public static finallong ANY_SERVICE_ID = 0;     public long serviceID;     public Class[ ]serviceTypes;     public Entry[ ] attributeSetTemplates; }

The “serviceTypes” element defines the types of the service. An item(item) matches a service template (tmpl) if item.serviceID equalstmpl.serviceID (or if tmpl.serviceID is zero) and item.service is aninstance of every type in tmpl.serviceTypes, and item.attributeSetscontains at least one matching entry for each entry template intmpl.attributeSetTemplates. Entry matching uses the following rule: anentry matches an entry template if the class of the entry is the sameas, or a superclass of, the class of the template and every non-nullfield in the template equals the corresponding field of the entry. Everyentry can be used to match more than one template. Both serviceTypes andattributeSetTemplates can be null in a service template.

The ServiceItemFilter interface defines the methods used by an object toapply additional matching criteria when searching for services on alookup service. This filtering mechanism is particularly useful toentities that wish to extend the capabilities of the standard templatematching schema previously discussed. For example, since templatematching does not allow one to easily search for services based on arange of attribute values, this additional matching mechanism can beexploited by the entity to ask the managing object to find allregistered printer services that have a resolution attribute between 300and 1200 dpi. As seen below, the “check” method defines theimplementation of the additional matching criteria to apply to aServiceItem object found through standard template matching. This methodtakes the Serviceltem object as the sole argument, to test against theadditional criteria. This method returns true if the input objectsatisfies the additional criteria, and false otherwise. public interfaceServiceItemFilter {     public boolean check(ServiceItem item); }

The ServiceMatches class is used for the return value when looking upmultiple items. The definition of this class follows: public classServiceMatches {     public ServiceItem[ ] items;     public inttotalMatches; }

The interface to the lookup service is defined by a ServiceRegistrarinterface data structure. This interface is not a remote interface.Instead, each implementation of the lookup service exports proxy objectsthat implement the ServiceRegistrar interface local to the client, usingan implementation-specific protocol to communicate with the actualremote server. “Proxy objects” refer to objects that run in the client'saddress space and that facilitate access to the lookup service. Methodsare provided to register service items, find items that match atemplate, modify attributes of existing items, receive notificationswhen items are modified, and incrementally explore the collection ofitems along the three major axes: service ID, service type, andattributes. The definition of the interface follows:     publicinterface ServiceRegistrar {         long REGISTRAR_SERVICE_ID = 1;        ServiceLease register (Service Item item, long lease expiration)throws RemoteException;         Object lookup (ServiceTemplate tmpl)            throws RemoteException         ServiceMatcheslookup(ServiceTemplate tmpl,         int maxMatches)             throwsRemoteException;         int addAttributes (ServiceTemplate tmpl,        Entry [ ] attrSets)             throws RemoteException;        int modifyAttributes(ServiceTemplate tmpl,         Entry [ ]attrSets)             throws RemoteException;         intTRANSITION_MATCH_NOMATCH = 1;         int TRANSITION_NOMATCH_MATCH = 2;        int TRANSITION_MATCH_MATCH = 3;         EventRegID notify(Service Template tmpl,                 int transition,                RemoteEventListener listener,                MarshalledObject handback,                 longleaseExpiration)             throws RemoteException;         Class [ ]getEntryClasses (ServiceTemplate tmpl)             throwsRemoteException;         Object [ ] getFieldValues (ServiceTemplatetmpl),                 int setIndex,                 String field)            throws NoSuchFieldException,             RemoteException;        Class [ ] getServiceTypes (Service Template tmpl,                  String packagePrefix             throwsRemoteException

This interface includes various methods, including the register method,the lookup method (single parameter form), the lookup method (twoparameter form), the addAttributes method, the modifyAttributes method,the notify method, the getEntryClass method, the getFieldValues method,and the getServiceTypes method. The “register” method is used toregister a new service and to re-register an existing service. Thismethod is defined so that it can be used in an idempotent fashion.Specifically, if a call results in generation of an exception (in whichcase the item might or might not have been registered), the caller cansimply repeat the call with the same parameters.

To register a new service using the register method, item.ServiceIDshould be zero; if item.ServiceID does not equal any existing item'sservice object, then a new unique service id will be assigned andreturned. The service id is unique over time with respect to this lookupservice. If item.ServiceID does equal an existing item's service object,the existing item is deleted from the lookup service (even if it hasdifferent attributes), but that item's service id is reused for thenewly registered item.

To re-register an existing service using the register method,item.ServiceID should be set to the same unique service id that wasreturned by the initial registration. If an item is already registeredunder the same service id, the existing item is deleted (even if it hasdifferent attributes or a different service instance). Note that serviceobject equality is not checked in this case to allow for reasonableevolution of the service (e.g., the serialized form of the stub changes,or the service implements a new interface).

When an item is registered, duplicate attribute sets are eliminated inthe stored representation of the item. Additionally, the registration ispersistent across restarts of the lookup service.

The single-parameter form of the “lookup” method returns the serviceobject (i.e., ServiceItem.service) from an item matching the template,or null if there is no match. If multiple items match the template, itis arbitrary as to which service object is returned. If the returnedobject cannot be deserialized, an exception is generated.

The two-parameter form of the “lookup” method returns at most maxMatchesitems matching the template, plus the total number of items that matchthe template. The return value is never null, and the returned itemsarray is only null if maxMatches is zero. For each returned item, if theservice object cannot be deserialized, the service field of the item isset to null and no exception is generated. Similarly, if an attributeset cannot be deserialized, that element of the attributeSets array isset to null and no exception is generated.

The “addAttributes” method adds the specified attribute sets (those thataren't duplicates of existing attribute sets) to all items matching thetemplate. The number of items that were matched is returned. Note thatthis operation has no effect on existing attribute sets of the matchingitems, and the operation can be repeated in an idempotent manner.

The “modifyAttributes” method is used to modify existing attribute sets.The lengths of tmpl.attributeSetTemplates and attrSets must be equal oran exception is generated. For each item that matches the template, theitem's attribute sets are modified as follows. For each array index I:if attrSets[i] is null, then every entry that matchestmpl.attributeSetTemplates[i] is deleted; otherwise, for every non-nullfield in attrSets [I], the value of that field is stored into thecorresponding field of every entry that matchestmpl.attributeSettemplates[i]. The class of attrSets[i] must be the sameas, or a superclass of, the class of tmpl.attributeSetTemplates [I], oran exception is generated. If the modification results in duplicateentries within an item, the duplicates are eliminated. The number ofitems that were matched is returned.

The “notify” method is used to register for event notification. Theregistration is leased, and the lease expiration request is exact. Theconcept of a lease is described in greater detail in U.S. patentapplication Ser. No. 09/044,923, entitled “Method and System for LeasingStorage,” which has previously been incorporated by reference. Theregistration is persistent across restarts of the lookup service untilthe lease expires or is canceled. The event id in the returnedEventRegld is unique at least with respect to all other active eventregistrations at this lookup service with different service templates oftransitions.

While the event registration is in effect, a notification containing anindication of the event is sent to the specified listener whenever aregister, lease cancellation or expiration, addattributes, ormodifyAttributes operation results in a service item changing state in away that satisfied the template and transition combination. A list ofthe transitions follows, although other transitions may also beimplemented within the scope of the present invention:

-   -   TRANSITION_MATCH_NOMATCH: an event is sent when the changed item        matches the template before the operation, but doesn't match the        template after the operation (this includes deletion of the        item).    -   TRANSITION_NOMATCH_MATCH: an event is sent when the changed item        doesn't match the template before the operation, (this includes        not existing), but does match the template after the operation.    -   TRANSITION_MATCH_MATCH: an event is sent when the changed item        matches the template both before and after the operation.

The “getEntryClasses” method looks at all items that match the specifiedtemplate, finds every entry among those items that either doesn't matchany entry templates or is a subclass of at least one match entrytemplate, and returns the set of the (most specific) classes of thoseentries. Duplicate classes are eliminated, and the order of classeswithin the returned array is arbitrary. Null (not a empty array) isreturned if there are no such entries or no matching items. If areturned class cannot be deserialized, that element of the returnedarray is set to null and no exception is thrown.

The “getFieldValue” method identifies all items that match the specifiedtemplate. This method returns the values of the items that match thespecified template.

The “getServiceTypes” method looks at all items that match the specifiedtemplate, and for every service object, this method finds every type(class or interface) of which the service object is an instance that isneither equal to, nor a superclass of, any of the service types in thetemplate, and returns the set of all such types that start with thespecified package prefix. Duplicate types are eliminated, and the orderof types within the returned array is arbitrary. Null (not an emptyarray) is returned if there are no such types. If a returned type cannotbe deserialized, that element of the returned array is set to null andno exception is thrown.

The Lookup Service Processing

FIGS. 3A and 3B depict a flowchart of the steps performed when a client,a program running on a particular device, makes use of the lookupservice 212. Initially, the device on which the client runs is connectedto the Jini distributed system (step 302). Next, the client sends amulti-cast packet containing code for communication with the client(step 304). In this step, the client is performing the discoveryprotocol as described in further detail in co-pending U.S. patentapplication Ser. No.09/044,945, entitled “Apparatus and Method forProviding Downloadable Code for Use in Communication With a Device in aDistributed System,” which has previously been incorporated byreference.

After the client sends the multi-cast packet, the discovery server 214receives the packet and uses the code contained in the packet to send areference to the lookup service to the client (step 306). After theclient receives the reference to the lookup service, the client is ableto utilize the interface of the lookup service to either add a service,delete a service, access a service, or request notification when thelookup service is updated, as reflected by steps 308-326.

At some point during the processing of the client, it may decide to adda service to the lookup service (step 308). If it decides to add aservice, the client adds a service to the lookup service by invoking theregister method, which sends to the lookup service either an objectrepresenting the service or a stub containing code and data tofacilitate access to the service (step 310). The addition of the stub tothe lookup service is described in greater detail in co-pending U.S.patent application Ser. No. 09/044,826, entitled “Method and System forFacilitating Access to a Lookup Service,” which has previously beenincorporated by reference.

Next, the client may decide to delete one of its services from thelookup service (step 312). If a client decides to do so, the clientdeletes the service from the lookup service by canceling the service'slease with the lookup service (step 314). It should be noted that boththe addition of service and the deletion of a service are donedynamically and in a manner that does not prohibit other clients fromusing the lookup service while the update occurs.

At some point later in the processing of the client, the client maydecide to access a service provided by the lookup service (step 316). Ifa client decides to access a service provided by the lookup service, theclient accesses the service by invoking the lookup method, whichretrieves from the lookup service either the object or the stubinformation for the service, and the client then either invokes methodson the object to use the service or uses the stub information to accessthe service (step 318). The step is described in greater detail inco-pending U.S. patent application Ser. No.09/044,826, entitled “Methodand System for Facilitating Access to a Lookup Service, ” which haspreviously been incorporated by reference.

The client may also request to be notified when an update occurs to thelookup service (step 320 in FIG. 3B). If a client wishes to be notified,the client invokes the notify method on the lookup service interface toregister a callback routine with the lookup service (step 322). A“callback routine” is a function that is invoked when the lookup serviceis updated. Additionally, the notify method allows the client toregister an object that will be passed back, via RMI, as a parameter tothe callback function.

Next, if an event has occurred for which the client wants to be notified(step 324), the registered callback routine is invoked by the lookupservice (step 326). In this step, the client is notified of theoccurrence of the event and can take appropriate action. For example, ifa service that the client was currently using has become unavailable,the client may store information so that it no longer uses it.

FIG. 4 depicts a flow chart of the steps performed by the lookup servicewhen performing event-related processing. Initially, the lookup servicereceives registrations from a number of clients interested in receivingnotifications when particular events occur (step 402). In this step, thelookup service receives the registrations via invocation of thenotification method on the lookup service interface and stores into atable, known as the event table, all of the associated information, suchas an indication of the client to be notified, a reference to thecallback routine, an object to be passed as a parameter to the callbackroutine, and an indication of the event in which the client isinterested. It should be noted that a client may register to be notifiedupon the occurrence of an event, or the client may register for a thirdparty to be notified. After receiving the registrations, the lookupservice determines whether an event occurred such that at least oneclient has registered an interest in the event (step 404). The lookupservice makes this determination by identifying when, for example, a newservice has been added to the lookup service, an existing service hasbeen deleted from the lookup service, or the attributes of a servicehave been modified. If such an event has not occurred, the eventnotification process of the lookup service remains in a wait state.

However, if an event has occurred, the lookup service determines allclients registered for notification for this event (step 406). Thelookup service makes this determination by accessing the event table.Next, the lookup service invokes the callback routines registered foreach client identified in step 406 (step 408). In this step, the eventtable contains a reference to the callback routine registered by eachclient, and the lookup service invokes each callback routine, passingthe registered objects as parameters, to notify the clients of theoccurrence of the event.

Alternative Embodiment

Since lookup services are generally located on a computer remote fromthe client, a query to a lookup service typically involves a remotecall. Such remote calls are much more costly in terms of processingoverhead and failure risk than are local procedure calls. This cost ismagnified when a client must make frequent queries for multipleservices. Such scenarios make it desirable for a client to internallystore references to discovered lookup services and network services ofinterest. This approach permits the client to identify and access lookupservices by simply searching a locally stored cache. It also providesthe capability for a client to efficiently react to network failures bymaintaining a redundant collection of network services. The processingoverhead required to perform these functions also makes it desirable todelegate the scheduling of them to a client lookup manager, and therebyfree the client to perform other functions. FIG. 8 depicts a clientcomputer in accordance with an alternate embodiment of the presentinvention. As shown in FIG. 8, computer 104, includes a memory 802,secondary storage device 804, CPU 806, input device 808, video display810, and Java runtime system 316. Client computer 104 additionallyincludes a client 812, a client lookup manager 814 and a cache 815. Theclient lookup manager 814 is implemented by a client lookup managerclass comprised of a helper utility class that any client 812 can use tocreate and populate a cache 815, and with which the client can registerfor notification of the availability of services of interest. A helperutility is a programming component that can be used during constructionof Jini services and/or clients. Helper utilities are not remote. Inother words, their methods typically do not execute on remote hosts.Consequently, they do not register with a lookup service and they areinstantiated locally by devices wishing to employ them.

In accordance with the alternate embodiment, when the client lookupmanager discovers a lookup service 212, the client lookup manager 814evaluates each of the associated network services and stores referencesto network services of interest in the local cache 815. As shown in FIG.9, when the client lookup manager receives a reference to a lookupservice (step 900), it extracts the network service (step 910) andevaluates whether the service is of interest to the client (step 920).If the service is of interest, the client lookup manager adds theservice to the cache in step 930 and process flows to step 940. If theservice is not of interest, process immediately flows to step 940 wherethe client lookup manager determines whether there are more networkservices available in the lookup service. If there are more servicesavailable, program execution returns to step 910, where another networkservice is extracted. If there are not any more network servicesavailable, process flows to step 950 where the client lookup managerdetermines whether there are any remaining undiscovered lookup services.If there are undiscovered lookup services, program execution returns tostep 900 and a new lookup service is discovered. In the event that alllookup services have been discovered, then the process of populating thecache is complete and program execution ends.

To perform the function of populating the cache as shown in step 920,the client lookup manager utilizes a complex filtering algorithm toextract any subset of network services desired by a client. As shown inFIG. 10, this process begins in step 1000 with a user inputting theServiceTemplate and ServiceItemFilter arguments described earlier. Asshown in step 1010, a null reference input to the template argument istreated as the equivalent of inputting a ServiceTemplate constructedwith all null arguments (all wildcards). That is, as shown in step 1030,the cache attempts to discover all services contained in a lookupservice. Otherwise, the cache attempts to discover services contained ineach lookup service that match the inputted criteria (step 1020). Next,the process performs the filtering specified by the ServiceItemFilterargument. In contrast to a null input to the ServiceTemplate aspreviously discussed, a null input to the filter argument (step 1040)has the opposite effect in that processing terminates and onlytemplate-matching will be employed to find the desired services.Otherwise, additional filtering in accordance with the inputted criteriawill be employed (step 1050) and the cache will be populatedaccordingly.

Once the cache is populated, the client lookup manager handles allactivities related to the cache including accessing, updating anddeleting the cache. For example, as shown in FIG. 11, when the clientdesires access to a service reference, it transmits a request, via alocal event to the client lookup manager (step 1100). In step 1110, theclient lookup manager searches the cache to determine whether aninstance of the requested service is stored in the cache. If the serviceis found (step 1120), the client lookup manager returns an instance ofthe requested service in step 1130 and the process ends. If, the serviceis not found, the client lookup manager returns a null reference in step1140, and the process terminates. Depending on the specificimplementation of the client lookup manager, the process can eitherre-institute a new search, wait for a new query request from the client,or re-query the associated lookup services.

As shown in FIG. 12, if a requested service reference is not found inthe cache or if an insufficient number of references is retrieved (inthe case of a client request for multiple references), the client lookupmanager can re-query the associated lookup services. As shown in step1200, this form of lookup takes as input an integer argument(MaxMatches) that represents the maximum number of matches that shouldbe returned. In other words, the object returned by this method willcontain no more than that number of service references, although it maycontain less. This method also takes an integer argument (WAIT) thatindicates the maximum amount of time the process is to wait beforereturning the identified service references. This argument prevents theclient lookup manager from attempting to discover a requested number ofMaxMatches for an infinite period of time. This feature is particularlyuseful to a user who is interested in choosing a service from a list ofpossible candidates instead of receiving a single service.

Once the ServiceTemplate, ServiceItemFilter, MaxMatches, and WAITarguments are input, the process proceeds to step 1210 where the methodaccesses a lookup service. In step 1220, the method retrieves a servicereference from the lookup service and in step 1230, determines whetherthe retrieved service reference is a qualifying service. If a qualifyingservice is found, the process proceeds to step 1240 and an array ofServiceltem objects is recorded. Otherwise, the process proceeds to step1250. After an array of ServiceItem objects is recorded in step 1240,the process then compares the number of identified matches with theMaxMatches value previously input (step 1260). If the number ofidentified matches equals the MaxMatches value, the process returns theidentified array of Serviceltem objects in step 1270 and the processterminates. Otherwise, the process proceeds to step 1250. As indicatedearlier, this process will wait a predetermined period of time for theclient lookup manager to identify the requested number of qualifyingservices. But, it returns immediately upon discovering the requestednumber of service references. In step 1250, the process determineswhether any more unexamined services exist inside the lookup service. Ifthere are more, process flows to step 1220 and another service referenceis retrieved. If there are no more services in the lookup service,process flows to step 1280 to determine whether any more unexaminedlookup services exist. If there are more lookup services, the processcontinues back to step 1210 to access another lookup service. If thereare no more unexamined lookup services in step 1280, the processproceeds to step 1290 where the method determines whether the WAITargument has been invoked (WAIT>=0) and if so, whether the duration hasbeen exceeded.

The “wait” feature is quite useful to entities that cannot proceed untilsuch a service of interest is found. As shown in FIG. 12, entitieswishing to employ this feature must input a positive value to the WAITargument which represents the number of milliseconds to wait for thedesired service or services to be discovered. If a non-positive value isinput to this argument, then this method will not wait. It will simplyquery all available lookup services once, and return the array ofidentified ServiceItem objects. If WAIT has been invoked and the elapsedtime exceeds the WAIT duration, the process continues to step 1270,returns the array of Serviceltem objects found thus far and then theprocess terminates. On the other hand, if WAIT has been invoked and theduration has not been exceeded, the process continues to step 1291 andthe client lookup manager registers with the event mechanism of thediscovered lookup services. The event mechanism requests the lookupservices notify the client lookup manager when one of the lookupservice's associated networks services changes. When a service changes,the client lookup manager determines whether the new service is aservice of interest in step 1292. If the service is of interest, it isrecorded in the Serviceltem array (step 1293). Otherwise, executionflows to step 1296 where the process determines whether the elapsed timeis less than or equal to the WAIT duration. If it is, the client lookupmanager waits to be notified of a new service. If the time has expired,the client lookup manager returns the array of ServiceItem objects foundthus far in step 1295. Once a service is recorded in the Serviceltemarray (step 1293) the client lookup manager determines whether thenumber of ServiceMatches is less than MaxMatches. If it is, executionflows to step 1296 where the process determines whether the elapsed timeis less than or equal to the WAIT duration. If the number ofServiceMatches is equal to MaxMatches, then the desired number ofservices has been found and process flows to step 1295 where theidentified array is returned. It should be obvious to those skilled inthe art that instead of an array of objects, this process could returnan instance of an object without departing from the scope of thisprocess. It should also be obvious to those skilled in the art thatinstead of returning when the total number of references equals themaxMatches object, this method could instead return once a minimumnumber of references (minMatches) have been found.

Just as the client may request that it be notified of state changes innetwork services occurring within each lookup service, as previouslydescribed in FIG. 4, so too can the cache request that it be notified.In other words, the client and the cache can separately be notified ofthe same or different events after receiving notification from a lookupservice. FIG. 13 shows the steps performed by the client lookup managerwhen either the cache or the client has requested event notification.First, as shown in step 1310, the lookup service observes a state changein a registered service. Next, the lookup service determines, in step1320, whether the event satisfies matching criteria specified by one ofits associated clients. If it does, the lookup service transmits theevent notification to the requesting client (step 1330) via a remoteevent. If the event does not satisfy matching criteria, the processends. Next, the cache (step 1350) determines whether the reported eventnecessitates a cache update. More specifically, since the cache mayreceive multiple events corresponding to the same service, it must firstdetermine whether it has previously been notified of this particularevent. For example, a particular service may be registered with morethan one lookup service or multiple configurations of the same servicecan be registered with a lookup service. When a lookup service reportsan event to a client, the lookup service has no way of knowing whetherthe event has previously been reported to the client via another lookupservice. If the cache has not previously been notified of this event,the cache is updated in step 1360. Otherwise, the process ends (note: ifthe cache has been previously notified, then the client has alsopreviously been notified). Once the cache has been updated, it nextdetermines whether the client is required to be notified as well (step1370). If the client requested notification, a notification message issent via local event to the client in step 1380 and the processterminates. This “many-to-one” relationship between the events receivedby the cache 815 and the events sent by the cache hides from the client812, the lookup services with which the cache 815 interacts. For manyentities that use the cache's event mechanism to interact with thecache's discovered services, knowledge of the number of distinct servicereferences, as well as identification of the lookup services with whichthose references are registered, is of no interest. Such entitiestypically are interested only in acquiring a reference—not allreferences to the services it needs to do its job. For entities whichare interested in this additional information, the cache 815 providesmethods separate from the event mechanism for obtaining thatinformation.

The Conference Room Example

Described below is an example use of the lookup service 212 with respectto a conference room 500 as depicted in FIG. 5. The conference room 500contains a printer 502, a fax machine 504, a computer 506, a projectionscreen 508, and a storage device 510, all interconnected by a network512. The computer 506 contains a lookup service 518 that defines allservices made available by the conference room Djinn. In this example,the user enters the conference room 500 with laptop 514. Such asituation occurs when a user with a laptop enters the conference room500 for a meeting. If the user wishes to make use of the servicesprovided by various devices in the conference room 500, the user mustjoin the Djinn of the conference room. In order to do so, the userconnects the laptop to the network 512 and runs a program, client 516,to perform the boot and join (or discovery) process, as described above.After the completion of the boot and join process, the client 516 (e.g.,a browser) receives a reference to the lookup service 518 defining theservices provided by the conference room Djinn. Using this reference,the client 516 downloads an applet from the lookup service 518 thatdisplays a screen 600, as shown in FIG. 6.

FIG. 6 depicts screen 600 displaying the available services of thelookup service 518 represented as various icons, including a printer602, a fax 604, a file system 606, and a projection screen 608. Thescreen 600 also displays an add service button 610. When the printericon 602 is selected, the stub code (i.e., service item) for the printeris downloaded to the client so that the client may make use of theprinter. Similarly, selection of the fax icon 604, the file system icon606, or the projection screen icon 608 downloads the appropriate stubinformation so that the client can use those services. The file systemicon 606 represents the file system of the computer 506.

The user, however, may want to add a service and thus selects the addservice button 610. Upon selection of the add service button 610, ascreen 700 is presented to the user as shown in FIG. 7. The screen 700depicts the available services of the laptop 514 which the user may addto the Djinn. For example, the available services on the laptop 514 mayinclude a Java space 702, the laptop file system 704, a database 706,and a dictionary 708. The user may select any of these services, whichare then automatically added to the lookup service and made available toother users of the Djinn.

Although methods and systems consistent with the present invention havebeen described with reference to a preferred embodiment thereof, thoseskilled in the art will know of various changes in form and detail whichmay be made without departing from the spirit and scope of the presentinvention as defined in the appended claims.

1-79. (canceled)
 80. A method in a distributed system comprised of aplurality of lookup services with associated network services and aclient lookup manager, the method comprising the steps of: receiving areference to one of said plurality of lookup services; and storing saidreference on said client lookup manager.
 81. The method according toclaim 80, further comprising: identifying at least one network serviceassociated with the lookup service; and storing a reference to saidnetwork service on said client lookup manager.
 82. The method accordingto claim 80, further comprising: identifying at least one networkservice associated with the lookup service; and storing said networkservice on said client lookup manager.
 83. A method in a distributedsystem comprised of a plurality of lookup services with associatednetwork services and a client lookup manager with an associated cache,the method comprising the steps of: receiving a request to access anetwork service; retrieving a reference to a lookup service from thecache, wherein said lookup service is associated with said networkservice; and sending a request to the lookup service identifying thenetwork service to be accessed.
 84. The method according to claim 83,wherein the retrieving step further comprises searching a table of aplurality of lookup services and associated network services for saidnetwork service.
 85. A method in a distributed system comprised of aplurality of lookup services with associated network services and aclient lookup manager with an associated cache, the method comprisingthe steps of: receiving a request to access a network service;transmitting said request to at least one of said plurality of lookupservices, provided a reference to said network service is not stored inthe cache; and retrieving a reference to a lookup service associatedwith the requested network service.
 86. A computer-readable mediumcontaining instructions for controlling a data processing system toperform a method for accessing network services, the data processingsystem having a software cache and a plurality of lookup servicesavailable for use in the data processing system, the method comprisingthe steps of: receiving a reference to one of said plurality of lookupservices; and storing said reference on said client lookup manager. 87.The computer-readable medium according to claim 86, further comprising:identifying at least one network service associated with the lookupservice; and storing a reference to said network service on said clientlookup manager.
 88. The computer-readable medium according to claim 86,further comprising: identifying at least one network service associatedwith the lookup service; and storing said network service on said clientlookup manager.
 89. A computer-readable medium containing instructionsfor controlling a data processing system to perform a method foraccessing network services, the data processing system having a softwarecache and a plurality of lookup services available for use in the dataprocessing system, the method comprising the steps of: receiving arequest to access a network service; retrieving a reference to a lookupservice from the cache, wherein said lookup service is associated withsaid network service; and sending a request to the lookup serviceidentifying the network service to be accessed.
 90. Thecomputer-readable medium according to claim 89, wherein the retrievingstep further comprises searching a table of a plurality of lookupservices and associated network services for said network service.
 91. Acomputer-readable medium containing instructions for controlling a dataprocessing system to perform a method for accessing network services,the data processing system having a software cache and a plurality oflookup services available for use in the data processing system, themethod comprising the steps of: receiving a request to access a networkservice; transmitting said request to at least one of said plurality oflookup services, provided a reference to said network service is notstored in the cache; and retrieving a reference to a lookup serviceassociated with the requested network service.
 92. A distributed systemcomprising: a server computer with a lookup service having references toa plurality of network services; and a client computer including aclient lookup manager with an associated cache, wherein said clientlookup manager: receives a reference to one of said plurality of lookupservices; and stores said reference on said client lookup manager.
 93. Adistributed system having a first computer with a client, a clientlookup manager with an associated cache, and a second computer with alookup service containing service references for accessing associatednetwork services, the distributed system comprising: means for receivinga reference to one of said plurality of lookup services; and means forstoring said reference on said client lookup manager.